package com.huiren.ui.configUI;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.annotation.PostConstruct;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ConfigJFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JDesktopPane desk = null;

	private JTabbedPane tabbedPane = null;
	@Autowired
	private JDBCConfigJPanel jdbcConfigJPanel;
	@Autowired
	private SqlConfigJPanel sqlConfigJPanel;
	@Autowired
	private GroupParamJPanel groupParamJPanel;
	@Autowired
	private CreateProcedureJPanel createProcedureJPanel;

	public ConfigJFrame() {

	}

	@PostConstruct
	public void initMethod() {
		this.getContentPane().setLayout(new BorderLayout(0, 0));
		this.setBounds(0, 0, 850, 700);
		this.setLocationRelativeTo(null); // 设置居中
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		desk = new JDesktopPane();
		desk.setVisible(true);
		desk.setBackground(Color.WHITE);
		this.getContentPane().add(desk);
		tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 800, 620);
		tabbedPane.add("数据库配置", jdbcConfigJPanel);
		tabbedPane.add("基本sql配置", sqlConfigJPanel);
		tabbedPane.add("入库分组配置", groupParamJPanel);
		tabbedPane.add("存储过程", createProcedureJPanel);
		tabbedPane.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent arg0) {
				switch (tabbedPane.getSelectedIndex()) {
				case 3:
					createProcedureJPanel.getParams();
					break;
				}
			}
		});
		desk.add(tabbedPane);
		this.setVisible(true);
	}
}
